﻿@{
    // ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="SearchBox  layui-form">
    赛季ID：
    <div class="layui-inline">
        <select name="contest_id" id="contest_id" lay-verify="required">
            <option value="-1">请选择</option>
            @{ foreach (SYJ.Model.Entities.Contest t in (List<SYJ.Model.Entities.Contest>)ViewBag.ContestList)
             {
                <option value='@t.id'> @t.title </option>
             }}
        </select>
    </div>
    图片状态：<div class="layui-inline">
           <select name="status" id="status" lay-verify="required">
               <option value="-1">请选择</option>
               <option value="0">正常</option>
               <option value="1">删除</option>
           </select>
    </div>
    是否分组：<div class="layui-inline">
             <select name="grouping" id="grouping" lay-verify="required">
                 <option value="-1">请选择</option>
                 <option value="0">单图</option>
                 <option value="1">分组</option>
             </select>
    </div>
    <button class="layui-btn" data-type="reload">搜索</button>
</div>

<table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>
<script>
    layui.use(['table', 'laytpl', 'layer'], function () {
        var table = layui.table;
        var laytpl = layui.laytpl;
        var layer = layui.layer;
        //方法级渲染
        table.render({
            elem: '#LAY_table_user'
          , url: '/admin/ContestPictureMgr/GetContestPictureList'
          , cols: [[
            { checkbox: true, fixed: true }
            , { field: 'id', title: 'ID', width: 80, fixed: true }
            , { field: 'contest_name', title: '赛季名称', width: 120 }
            , { field: 'user_name', title: '用户名称', width: 200 }
            , { field: 'picture_name', title: '照片名称', width: 150 }
            , { field: 'title', title: '自定义名称', width: 120 }
            , { field: 'label', title: '标签', width: 120 }
            , { field: 'create_time', title: '添加时间', width: 130, templet: '#time_tpl' }
            , { field: 'status', title: '状态', width: 80, templet: '#status_tpl' }
            , { field: 'set', title: '操作', align: 'center', width: 200, toolbar: '#set_tool' }
          ]]
            , id: 'tid'
            //,skin: 'line' //风格
            , even: false
            , limits: [15, 30, 50]
            , limit: 15
            , loading: true
            , page: true
            , requert: {
                pageName: 'PageIndex' //页码的参数名称，默认：page
                , limitName: 'PageSize' //每页数据量的参数名，默认：limit
            }
            , height: 'full-240'
        });

        var $ = layui.$, active = {
            reload: function () {
                table.reload('tid', {
                    where: {
                        contest_id: $('#contest_id').val(),
                        status: $("#status").val(),
                        grouping: $('#grouping').val()
                    }
                });
            }
        };

        $('.SearchBox .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    function deleteRole(rid) {
        deleteById("/admin/ContestPicture/Delete", { id: rid });
    }

    function update(id) {
        layer.open({
            type: 2,
            title: '修改照片信息',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area: ['800px', '650px'],
            content: 'AddOrUp?id=' + id
        });
    }
</script>

<script type="text/html" id="status_tpl">


    {{#  if(d.status==0){ }}
    <span class="layui-badge-rim layui-bg-cyan">正常</span>
    {{#  } else { }}
    <span class="layui-badge-rim layui-bg-gray">退赛</span>
    {{#  } }}
</script>

<script type="text/html" id="time_tpl">

    {{#  if(d.create_time!= ""){ }}
   
   {{ timeFormat(d.create_time) }}
    {{#  } }}

</script>

<script type="text/html" id="set_tool">
    <button class="layui-btn layui-btn-mini layui-btn-normal" onclick="update('{{ d.id }}')">
        <i class="layui-icon">&#xe642;</i>修改
    </button>
    <button class="layui-btn layui-btn-mini layui-btn-danger" onclick="deleteRole('{{ d.id}}')">
        <i class="layui-icon">&#xe640;</i>删除
    </button>
</script>

